$(() => {
    let infant_mom_title_wrapper = $(".infant_mom_title");
    let infant_mom_content_wrapper = $(".infant_mom_content");
    let life_home_appliance_title_wrapper = $(".life_home_appliance_title");
    let life_home_appliance_content_wrapper = $(".life_home_appliance_content");
    let suning_international_title_wrapper = $(".suning_international_title");
    let suning_international_content_wrapper = $(".suning_international_content");
    let suning_appliance_title_wrapper = $(".suning_appliance_title");
    let suning_appliance_contentt_wrapper = $(".suning_appliance_content");
    let suning_supermarket_title_wrapper = $(".suning_supermarket_title");
    let suning_supermarket_content_wrapper = $(".suning_supermarket_content");
    let mobile_phone_title_wrapper = $(".mobile_phone_title");
    let mobile_phone_content_wrapper = $(".mobile_phone_content");

    // 母婴玩具
    let infant_mom_title_options = {
        url: "../json/index_maternal_and_infant_toys.json"
    }
    $.ajax(infant_mom_title_options)
        .then(res => {
            let res_title = res.title;
            let res_data = res.data;
            let res_title_str = "";
            let res_data_str = "";

            for (let attr in res_title) {
                res_title_str += `  <div class="classify">
                                        ${res_title[attr].name}
                                    </div>
                                    <div class="describe">
                                        ${res_title[attr].slogan}
                                    </div>`
            }
            infant_mom_title_wrapper.html(res_title_str);

            for (let attr in res_data) {
                res_data_str += `   <p>
                                        <img src="${res_data[attr].img_url}" alt="">
                                    </p>`
            }
            infant_mom_content_wrapper.html(res_data_str);
        })

    // 生活家电
    let life_home_appliance_options = {
        url: "../json/index_life_home_appliance.json"
    }
    $.ajax(life_home_appliance_options)
        .then(res => {
            let res_title = res.title;
            let res_data = res.data;
            let res_title_str = "";
            let res_data_str = "";
            for (let attr in res_title) {
                res_title_str += `  <div class="classify">
                                        ${res_title[attr].name}
                                    </div>
                                    <div class="describe">
                                    ${res_title[attr].slogan}
                                    </div>`
            }
            life_home_appliance_title_wrapper.html(res_title_str);

            for (let attr in res_data) {
                res_data_str += `   <p>
                                        <img src="${res_data[attr].img_url}" alt="">
                                    </p>`
            }
            life_home_appliance_content_wrapper.html(res_data_str);
        })

    // 苏宁国际
    let suning_international_options = {
        url: "../json/index_suning_international.json"
    }
    $.ajax(suning_international_options)
        .then(res => {
            let res_title = res.title;
            let res_data = res.data;
            let res_title_str = "";
            let res_data_str = "";
            for (let attr in res_title) {
                res_title_str += `  <div class="classify">
                                        ${res_title[attr].name}
                                    </div>
                                    <div class="describe">
                                    ${res_title[attr].slogan}
                                    </div>`
            }
            suning_international_title_wrapper.html(res_title_str);

            for (let attr in res_data) {
                res_data_str += `   <p>
                                        <img src="${res_data[attr].img_url}" alt="">
                                    </p>`
            }
            suning_international_content_wrapper.html(res_data_str);
        })

    // 苏宁家电
    let index_home_appliance_options = {
        url: "../json/index_home_appliance.json"
    }
    $.ajax(index_home_appliance_options)
        .then(res => {
            let res_title = res.title;
            let res_data = res.data;
            let res_title_str = "";
            let res_data_str = "";
            for (let attr in res_title) {
                res_title_str += `  <div class="classify">
                                            ${res_title[attr].name}
                                        </div>
                                        <div class="describe">
                                        ${res_title[attr].slogan}
                                        </div>`
            }
            suning_appliance_title_wrapper.html(res_title_str);

            for (let attr in res_data) {
                res_data_str += `   <p>
                                            <img src="${res_data[attr].img_url}" alt="">
                                        </p>`
            }
            suning_appliance_contentt_wrapper.html(res_data_str);
        })

    // 苏宁超市
    let suning_supermarket_options = {
        url: "../json/index_suning_supermarket.json"
    }
    $.ajax(suning_supermarket_options)
        .then(res => {
            let res_title = res.title;
            let res_data = res.data;
            let res_title_str = "";
            let res_data_str = "";
            for (let attr in res_title) {
                res_title_str += `  <div class="classify">
                                                ${res_title[attr].name}
                                            </div>
                                            <div class="describe">
                                            ${res_title[attr].slogan}
                                            </div>`
            }
            suning_supermarket_title_wrapper.html(res_title_str);

            for (let attr in res_data) {
                res_data_str += `   <p>
                                                <img src="${res_data[attr].img_url}" alt="">
                                            </p>`
            }
            suning_supermarket_content_wrapper.html(res_data_str);
        })

    // 爆款手机
    let mobile_phone_options = {
        url: "../json/index_apparel_textile.json"
    }
    $.ajax(mobile_phone_options)
        .then(res => {
            let res_title = res.title;
            let res_data = res.data;
            let res_title_str = "";
            let res_data_str = "";
            for (let attr in res_title) {
                res_title_str += `  <div class="classify">
                                                ${res_title[attr].name}
                                            </div>
                                            <div class="describe">
                                            ${res_title[attr].slogan}
                                            </div>`
            }
            mobile_phone_title_wrapper.html(res_title_str);

            for (let attr in res_data) {
                res_data_str += `   <p>
                                                <img src="${res_data[attr].img_url}" alt="">
                                            </p>`
            }
            mobile_phone_content_wrapper.html(res_data_str);
        })
})